<?php

namespace app\http\middleware;
use think\Db;
use lib\Tool;
use think\Controller;


class Category extends Controller
{
    public function handle($request, \Closure $next)
    {
        if($request->controller() == 'Article' || ($request->controller() == 'Category' && $request->action() == 'create')){
            $category = db::table('yu_category')->select();
            $re = Tool::tree($category);
            $this->assign('category',$re);
        }
        return $next($request);
    }
}
